#ifndef PI_H
#define PI_H

class PIController {
public:
    // Constructor with default parameters
    PIController(float kp = 0.1f, float ki = 1.0f/5000.0f, float limit = 5.0f);
    
    // Reset controller state
    void reset();
    
    // Update controller with new input
    // Returns control output
    float update(float setpoint, float feedback);
    
    // Get current state
    float getIntegralState() const { return ui; }
    bool isIntegralClamped() const { return integral_clamped; }

private:
    const float kp;              // Proportional gain
    const float ki;              // Integral gain
    const float output_limit;    // Output saturation limit
    
    float ui;                    // Integral state
    bool integral_clamped;       // Integral anti-windup flag
};

#endif // PI_H
